from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time
testCase="DBshop011_商品管理管理商品添加商品"
goodsName="苹果XR"
price=7999
# 1.点击添加商品按钮，商品名称填写“苹果XR”,本店价格“7999”，商品类型“虚拟商品”。
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"商品管理","管理商品")
firefox.find_element_by_partial_link_text("添加商品").click()
firefox.find_element_by_id("goods_name").send_keys(goodsName)
firefox.find_element_by_id("goods_shop_price").send_keys(price)
firefox.find_element_by_xpath("//select[@id='goods_type']/option[@value='2']").click()
# 2.点击“保存商品”按钮，后台保存成功添加的商品。
firefox.find_element_by_xpath("//button[contains(.,'保存商品')]").click()
time.sleep(2)
if firefox.find_element_by_xpath(
        "//td[contains(.,'%s')]/following-sibling::td[6]/a[contains(.,'编辑')]"%goodsName).is_displayed():
    writeLog("%s 测试通过"%testCase)
else:
    writeLog("%s 测试失败"%testCase)
    getPhoto(firefox)
firefox.quit()